package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.ElderDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import com.zzyl.nursing.vo.app.DeviceDataElderVo;
import com.zzyl.nursing.vo.app.PropertyStatusInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }


    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public R addelderdate(@RequestBody ElderDto elderDto){
        familyMemberService.addelderdate(elderDto);
        return R.ok();
    }


    @GetMapping("/my")
    @ApiOperation("查询我的家人")
    public R<List<FamilyElderVo>> selectMyElder(){
        List<FamilyElderVo>  list = familyMemberService.selectMyElder();
        return R.ok(list);
    }


    @GetMapping("/list-by-page")
    @ApiOperation("分页查询")
    public R<List<FamilyElderDetailVo>> listPageMember(@RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,@RequestParam(value = "pageSize", required = false, defaultValue ="10") Integer pageSize){
        List<FamilyElderDetailVo> list = familyMemberService.listPageMember(pageNum, pageSize);
        return R.ok(list);
    }

    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation("查询健康数据")
    public R<List<PropertyStatusInfoVo>> QueryDevicePropertyStatus(@PathVariable String iotId){
        List<PropertyStatusInfoVo> list =  familyMemberService.QueryDevicePropertyStatus(iotId);
        return R.ok(list);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("查询每小时设备数据")
    public R<List<DataHourDetailVo>> queryDeviceDataListByDay(@RequestParam String iotId,@RequestParam String functionId , @RequestParam Long startTime, @RequestParam Long endTime){
        List<DataHourDetailVo> list =  familyMemberService.queryDeviceDataListByDay(iotId,functionId,startTime,endTime);
        return R.ok(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("查询每日设备数据")
    public R<List<DataWeekDetailVo>> queryDeviceDataListByWeek(@RequestParam String iotId, @RequestParam String functionId , @RequestParam Long startTime, @RequestParam Long endTime){
        List<DataWeekDetailVo> list =  familyMemberService.queryDeviceDataListByWeek(iotId,functionId,startTime,endTime);
        return R.ok(list);
    }






}
